unit CDS_DM;

interface

uses
  System.SysUtils, System.Classes, Data.DBXDataSnap, IndyPeerImpl, Forms,
  DBClient, Data.DBXCommon, Datasnap.DSHTTPLayer, Data.DB, Data.SqlExpr, IPPeerClient,
  ServerMethods;

type
  TdmCDS = class(TDataModule)
    Connection: TSQLConnection;
    procedure DataModuleCreate(Sender: TObject);
    procedure DataModuleDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    Methods: TServerMethodsClient;
  end;

var
  dmCDS: TdmCDS;

implementation

uses Login;
{ %CLASSGROUP 'System.Classes.TPersistent' }

{$R *.dfm}

procedure TdmCDS.DataModuleCreate(Sender: TObject);
begin
  Connection.Connected := False;
  {
  if Connection.Connected then
    raise Exception.Create('Connection is active in design mode.');
  }

  Logon(Connection);
  if not Application.Terminated then
    Methods := TServerMethodsClient.Create(Connection.DBXConnection);
end;

procedure TdmCDS.DataModuleDestroy(Sender: TObject);
begin
  Logoff(Connection);
  Methods.Free;
end;

end.
